<template>
	<!-- 秒杀楼层 -->
	<view class="seckill-section m-t">
		<view class="s-header">
			<image class="s-img" src="/static/temp/secskill-img.jpg" mode="widthFix"></image>
			<text class="tip">8点场</text>
			<text class="hour timer">07</text>
			<text class="minute timer">13</text>
			<text class="second timer">55</text>
			<text class="iconfont icon-arrow-right"></text>
		</view>
		<scroll-view class="floor-list" scroll-x>
			<view class="scoll-wrapper">
				<view v-for="(item, index) in goodsList" :key="index" class="floor-item" @click="navToDetailPage(item)">
					<image :src="item.image" mode="aspectFill"></image>
					<text class="title clamp">{{item.title}}</text>
					<text class="price">
						<text class="pr-child hasborder">特价</text>
						<text class="pr-child">￥{{item.price}}</text>
					</text>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				goodsList: []
			};
		},
		mounted() {
			this.loadData();
		},
		methods: {
			/**
			 * 请求静态数据只是为了代码不那么乱
			 * 分次请求未作整合
			 */
			async loadData() {
				let goodsList = await this.$api.json('goodsList');
				this.goodsList = goodsList || [];
			},
			//详情页
			navToDetailPage(item) {
				//测试数据没有写id，用title代替
				let id = item.title;
				uni.navigateTo({
					url: `/pages/product/product?id=${id}`
				})
			}
		}
	}
</script>

<style lang="scss">
	/* 秒杀专区 */
	.seckill-section {
		padding: 4upx 30upx 24upx;
		background: #fff;

		// 头部倒计时
		.s-header {
			display: flex;
			align-items: center;
			height: 92upx;
			line-height: 1;

			.s-img {
				width: 140upx;
				height: 30upx;
			}

			.tip {
				font-size: $font-base;
				color: $font-color-light;
				margin: 0 20upx 0 40upx;
			}

			.timer {
				display: inline-block;
				width: 40upx;
				height: 36upx;
				text-align: center;
				line-height: 36upx;
				margin-right: 14upx;
				font-size: $font-sm+2upx;
				color: #fff;
				border-radius: 8upx;
				background: rgba(0, 0, 0, .8);
			}

			.icon-arrow-right {
				// font-size: calc($font-lg + 20upx);
				margin-right: 8upx;
				color: $font-color-light;
				flex: 1;
				text-align: right;
			}
		}

		// scroll-x部分
		.floor-list {
			white-space: nowrap;

			.scoll-wrapper {
				display: flex;
				align-items: flex-start;

				.floor-item {
					width: 150upx;
					margin-right: 20upx;
					font-size: $font-sm+2upx;
					color: $font-color-dark;
					line-height: 1.8;

					image {
						width: 150upx;
						height: 150upx;
						border-radius: 6upx;
					}

					.price {
						// color: $uni-color-error;
						// background-color: $border-color-dark;
						// margin-left: .06rem;
						display: flex;
						align-items: center;
						height: 40upx;
						// line-height: 30upx;
						padding: 10upx 0;
						background-color: #f8d300;
						border-radius: 6upx;
						font-size: 24upx;
						color: #222;
						.pr-child {
							padding-left: 4upx;
							padding-right: 4upx;
							// margin: 8upx 0;
						}
						.hasborder {
							margin-left: 2upx;
							border-right: 1px dotted #222;
						}
					}
				}
			}
		}




	}
</style>
